<template>
  <div>
    <div class="block">
      <el-row>
        <!-- 工程设备 -->
        <el-col>
          <span class="demonstration" style="font-size: 25px;font-weight: bold;padding: 10px;">工程设备</span>
        </el-col>
        <el-col>
          <el-cascader :props="{ label: 'name', value: 'id' }" :options="repData" @change="handlerChange"></el-cascader>
        </el-col>
      </el-row>
      <!-- 报修原因 -->
      <el-row>
        <el-col>
          <span class="demonstration"
            style="font-size: 25px;font-weight: bold;margin-top: 20px;padding: 10px;">报修原因</span>
        </el-col>
        <el-col>
          <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="params.bill_why">
          </el-input>
        </el-col>
      </el-row>
      <el-row>
        <el-button type="primary" @click="toSubmit">提交</el-button>
      </el-row>
    </div>
  </div>
</template>

<script>
import { get, postJSON } from '@/utils/request'
export default {
  data() {
    return {
      textarea: '',
      repData: [],
      params: {}
     
    };
  },
  computed: {},
  methods: {
    async toSubmit() {
      let res = await postJSON('/workorder/repairOrder', this.params);
      this.$message({
        type: 'success',
        message: res.message,
      });
      // 页面跳转 
      this.$router.push({
        path: '/am/order/List',
      })
    },
    async getPepData() {
      let res = await get('/engineer/findEngineerDeviceTree');
      this.repData = res.data;
    },
    handlerChange(value) {
      this.params.engineer_id = value[0];
      this.params.device_id = value[1];
      this.params.account_id = 1;
    }
  },
  created() {
    this.getPepData();
  },
  mounted() { },
};
</script>
<style scoped></style>